package com.thoughtworks.Java;

import com.thoughtworks.Java.repository.CustomerRepository;
import com.thoughtworks.Java.repository.CustomerRepositoryImpl;
import com.thoughtworks.Java.service.CustomerService;
import com.thoughtworks.Java.service.CustomerServiceImpl;
import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

/**
 * Created by yrzhang on 10/9/16.
 */
@Configuration
@ComponentScan({"com.thoughtworks.java"})
@PropertySource("app.properties")
public class AppConfig {

    @Bean(name = "customerRepository")
    public CustomerRepository getCustomerRepository() {
        return new CustomerRepositoryImpl();
    }

    @Bean(name = "customerService")
    public CustomerService getCustomerService() {
        CustomerServiceImpl customerService = new CustomerServiceImpl(getCustomerRepository());

        return customerService;
    }

    @Bean
    public static PropertySourcesPlaceholderConfigurer getPropertySourcesPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }
}
